from apps.codetable.filters import CodeTableFilter
from apps.codetable.models import CodeTableDetail
from apps.codetable.serializers import CodeTableSerializer
from bases.viewsets import APIReadOnlyViewSet
from constants import LANGUAGE_ZH


class CodeTableViewSet(APIReadOnlyViewSet):
    def get_queryset(self):
        localization = getattr(self.request, 'LANGUAGE_CODE', LANGUAGE_ZH)
        return CodeTableDetail.objects.filter(localization=localization).order_by('id')

    serializer_class = CodeTableSerializer
    pagination_class = None

    filter_class = CodeTableFilter
